#define _CRT_SECURE_NO_WARNINGS 1

#include<stdlib.h>

void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n)
{
    int* arr = (int*)malloc(sizeof(int) * nums1Size);
    int begin1 = 0, begin2 = 0;
    int index = 0;
    while (begin1 < m && begin2 < n)
    {
        if (nums1[begin1] < nums2[begin2])
        {
            arr[index++] = nums1[begin1++];
        }
        else
        {
            arr[index++] = nums2[begin2++];
        }
    }
    while (begin1 < m)
    {
        arr[index++] = nums1[begin1++];
    }
    while (begin2 < n)
    {
        arr[index++] = nums2[begin2++];
    }
    for (int i = 0; i < nums1Size; i++)
    {
        nums1[i] = arr[i];
    }
}